package com.wzy.Jdbc封装.controller;

import com.wzy.Jdbc封装.pojo.News_user;
import com.wzy.Jdbc封装.service.Impl.option_News_userImpl;
import com.wzy.Jdbc封装.service.option_News_user;

import java.sql.SQLException;
import java.util.List;

public class News_userController {
    //注入服务层
    private static option_News_user news_user = new option_News_userImpl();

    //根据id查询信息
    public static void select(News_user user)throws SQLException{
        List<News_user> list = news_user.selectById(user);
        for (News_user u : list){
            System.out.println(u.getId()+"-------"+u.getUserName()+"-------"+u.getPassword()+"-------"+u.getEmail()+"-------"+u.getUserType());
        }
    }

    //根据id删除信息
    public  static  void delete(News_user user) throws SQLException {
        int i = news_user.deleteById(user);
        System.out.println(i>0?"删除成功":"删除失败");
    }

    //根据id修改名称name
    public  static  void update(News_user user) throws SQLException {
        int i = news_user.updateById(user);
        System.out.println(i>0?"修改成功":"修改失败");
    }

    //新增信息
    public  static  void insert(News_user user) throws SQLException {
        int i = news_user.insertNews(user);
        System.out.println(i>0?"新增成功":"新增失败");
    }

}
